﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BattleGroundHelper : MonoBehaviour {
	public static BattleGroundHelper instance;
	public GameObject battleGround;
	public MeshRenderer mesh;
	public Material[] bgMat;

	private void OnEnable()
	{
		if (!battleGround)
			battleGround = transform.GetChild (0).gameObject;
		if (mesh == null)
			mesh = battleGround.GetComponent<MeshRenderer> ();
	}
	public static void SetBackground()
	{
		instance.mesh.material = instance.bgMat [GameManager.CurrMap];
	}
	private void Awake()

	{
		instance = this;
	}
	private void Start()
	{
		SetBattleGroundScale ();
	}

	public void SetBattleGroundScale()
	{
		var ySize = Camera.main.orthographicSize * 2;
		var xSize = (ySize * Screen.width) / Screen.height;
		battleGround.transform.localScale = new Vector2 (xSize, ySize);
	}
}
